==<template>
    <!--    <div>载体</div>-->
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch">
            <el-form-item label="数据包名称" >
                <el-input v-model="queryParams.title" placeholder="请输入数据包名称" clearable style="width: 240px"
                    @keyup.enter.native="handleQuery" />
            </el-form-item>
            <el-form-item label="接收日期" >
                <el-date-picker v-model="queryParams.receivingTime" type="date" placeholder="选择日期" format="yyyy-MM-dd" value-format="yyyy-MM-dd" >
                </el-date-picker>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
            </el-form-item>
        </el-form>
        <el-row :gutter="10" class="mb8" ref="refbut">
            <el-col :span="1.5">
                <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd">添加</el-button>
            </el-col>
            <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
        </el-row>

        <el-table ref="table" v-loading="loading" :data="dataList" :height="tableHeight"
            @selection-change="handleSelectionChange" border stripe>
            <el-table-column type="selection" width="50" align="center" fixed="left" />
            <el-table-column label="序号" sortable align="center" type="index" prop="id" />
            <el-table-column label="数据包名称" prop="title" align="center" :show-overflow-tooltip="true" />
            <el-table-column label="大小(字节)" prop="size" align="center" :show-overflow-tooltip="true" />
            <el-table-column label="保存时间（年）" prop="saveTime" align="center">
                <template slot-scope="scope">
                   
                   <span v-for="item in dict.type.BGQX" :key="item">{{ scope.row.saveTime==item.value?item.label:"" }}</span>
                </template>
            </el-table-column>
            <el-table-column label="接收日期" prop="receivingTime" align="center"></el-table-column>
            <el-table-column label="格式" prop="format" align="center"></el-table-column>
            <el-table-column label="存储路径" prop="path" align="center"></el-table-column>
            <el-table-column label="是否解析" prop="title" align="center" :show-overflow-tooltip="true">
                <template slot-scope="scope">
                    {{ scope.row.resolved=='1'?'是':'否' }}
                </template>
            </el-table-column>
            <el-table-column label="是否通过检测" prop="sixing" align="center">
                <!--200 四性检测通过，400四性检测不通过，”“未检测-->
                <template slot-scope="scope">
                    <span v-if="scope.row.sixing == '200'">通过</span>
                    <span v-else-if="scope.row.sixing == '400'">不通过</span>
                    <span v-else>未检测</span>
                </template>
            </el-table-column>
            <el-table-column label="备注" prop="remark" align="center"></el-table-column>
            <el-table-column label="操作" align="center" width="300px">
                <template slot-scope="scope">
                    <el-button plain type="success" size="mini" @click="handleUpdate(scope.row)"
                        v-if="scope.row.sixing == '' || scope.row.sixing == null">修改</el-button>
                    <el-button plain type="danger" size="mini" @click="handledelete(scope.row)"
                        v-if="scope.row.sixing == '' || scope.row.sixing == null || scope.row.sixing == '400'">删除</el-button>
                    <el-button plain type="warning" size="mini" @click="handleJC(scope.row)"
                        v-if="scope.row.sixing == '400'||scope.row.sixing == ''||scope.row.sixing == null">合规性检测</el-button>
                    <el-button plain type="info" size="mini" @click="handleRestore(scope.row)"
                        v-if="scope.row.sixing == '200'">目录解析</el-button>
                        <!-- <el-button plain type="info" size="mini" @click="handleCope(scope.row)" >磁盘拷贝</el-button>   -->
                </template>
            </el-table-column>
        </el-table>
        <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
            @pagination="getList" />
        <deit v-if="deitOpen" :deitOpen="deitOpen" @closeDelDialog="closeDelDialog" :Id="id" @addsubmitForm="addsubmitForm">
        </deit>

        <!-- start  检测方案弹窗 -->
        <el-dialog title="请选择检测方案" :visible.sync="dialogVisible" width="20%" :before-close="handlecloseDelDialog"
            :close-on-click-modal="false">
            <el-select v-model="sxjcType" placeholder="请选择" style="width:100%">
                <el-option v-for="item in sxjcList" :key="item.identification" :label="item.identification"
                    :value="item.identification">
                </el-option>
            </el-select>
            <span slot="footer" class="dialog-footer">
                <el-button type="primary" @click="handleYes">确 定</el-button>
            </span>
        </el-dialog>
        <!-- end  检测方案弹窗-->
    </div>
</template>
    
<script>
import estimateTableHeight from "@/mixins/estimateTableHeight";
import { getTableList, datamanagerDelete,fourCheck,dirParsing} from "@/api/cqbc/dataManage/receiveDetection.js"
import deit from "@/views/cqbc/dataManage/receiveDetection/deit.vue"
import { getdetectionSchemeList } from '@/api/archive/archiveTransfer/archiveTransfer.js'
export default {
    mixins: [estimateTableHeight], // 混入方法
    archive_Dicts: ['CARRIER_TYPE','BGQX'],
    components: {
        deit
    },
    data() {
        return {
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            // 显示搜索条件
            showSearch: true,
            dataList: [],
            total: 0,
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                title: undefined,
                receivingTime:undefined
            },
            deitOpen: false,
            id: undefined,
            sxjcList:[],
            dialogVisible: false, //检测方案弹窗
            sxjcType:undefined,
            rows:"",
            
        }
    },
    created() {
        this.getList()
    },
    methods: {
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
        closeDelDialog() {
            this.deitOpen = false;
        },
        handleAdd() {
            this.id = undefined;
            this.deitOpen = true;
        },
        getList() {
            console.log(this.queryParams)
            getTableList(this.queryParams).then(response => {
                this.dataList = response.rows
                this.total = response.total
                this.loading = false
            })
        },


        handleQuery() {
            this.getList();
        },

        resetQuery() {
            this.queryParams = {
                pageNum: 1,
                pageSize: 10,
                receivingTime: undefined,
                title: undefined
            },
                this.getList();
        },
        handledelete(row) {
            const id = row.id || this.ids
            this.$modal.confirm('是否确认删除数据包名称为"' + row.title + '"的数据项？').then(function () { }).then(() => {
                datamanagerDelete(id).then(res => {
                    if (res.code == "200") {
                        this.$modal.msgSuccess("删除成功");
                        this.getList();
                    }
                })
            }).catch(() => { });
        },
        //修改
        handleUpdate(row) {
            this.deitOpen = true;
            this.id = row.id;
        },
        addsubmitForm() {
            this.deitOpen = false;
            this.getList();
        },


        //合规性检测
        handleJC(row) {
            this.rows=row;
            this.sxjcType=undefined;
            this.getdetectionSchemeListPOST(row.category);
        },

        /**四性检测方案列表 */
        getdetectionSchemeListPOST(categoryId) {
            getdetectionSchemeList({
                state: "1",
                phase: "2",
                categoryId:categoryId,
            }).then(res => {
                if (res.rows.length > 0) {
                    this.sxjcList = res.rows
                    this.dialogVisible = true;
                } else {
                    this.$message({ message: '当前门类数据还没有四性检测方案数据', type: 'warning' })
                }
            })
        },

        handlecloseDelDialog() {
            this.sxjcType = undefined
            this.dialogVisible = false
        },



        //进行检测
        handleYes(){
            if(this.sxjcType==undefined ){
                this.$message({ message: '请先选择检测方案！', type: 'warning' })
                return false;
            }
            fourCheck({
                code:this.sxjcType,
                path:this.rows.path,
                id:this.rows.id
            }).then(res=>{
                if(res.code=="200"){
                    this.$modal.msgSuccess("检测成功");
                    this.dialogVisible = false
                    this.getList();
                }
            })
        },


        //目录解析
        handleRestore(row){
            console.log(row)
            if(row.resolved=='1'){
                this.$message({ message: '当前数据已经解析完成', type: 'warning' })
                return false
            }
            dirParsing({
                id:row.id,
                format:row.format,
                name:row.name,
                path:row.path,
                zlfs:row.zlfs,
                category:row.category
            }).then(res=>{
                if(res.code=="200"){
                    this.$modal.msgSuccess("解析成功");
                    this.getList();
                }
            })
        },

        //磁盘拷贝
        handleCope(row){
            moveItem({
                id:row.id
            }).then(res=>{

            })
        },

    }
}
</script>
    
<style></style>
    